package App;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import javax.servlet.MultipartConfigElement;

@Slf4j
@SpringBootApplication
@EnableScheduling
//@ComponentScan("App.Config.BeanConfig")
public class ClientApplication {


    public static void main(String[] args) {

        ConfigurableApplicationContext ctx = SpringApplication.run(ClientApplication.class, args);

        //get database config
        /*String _url = ctx.getEnvironment().getProperty("spring.datasource.url");
        System.out.println("____________________url:"+_url);
        String _username = ctx.getEnvironment().getProperty("spring.datasource.username");
        String _password = ctx.getEnvironment().getProperty("spring.datasource.password");


        ConnectionInfo _connectionInfo = new ConnectionInfo();
        _connectionInfo.setUrl(_url);
        _connectionInfo.setUsername(_username);
        _connectionInfo.setPassword(_password);
        ConnectinManager.setConnectionInfo(_connectionInfo);*/

        // load task schedule
        //ScheduleService _scheduleService = new ScheduleService();
        //_scheduleService.loadTaskSchedule(_url, _username, _password);
    }


    //设置上传文件的尺寸
    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //单个文件最大
        factory.setMaxFileSize("102400KB"); //KB,MB
        /// 设置总上传数据总大小
        factory.setMaxRequestSize("102400KB");

        return factory.createMultipartConfig();
    }


}
